package cn.edu.scau.cmi.linhuanrui.simpleFactoryMethod;

import javafx.fxml.FXML;

import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.event.ActionEvent;
import javafx.scene.control.TextArea;

public class SimpleFactoryController {
	@FXML
	private TextField input;
	@FXML
	private TextArea showText;
	@FXML
	private Button ok;

	// Event Listener on TextField[#input].onAction
	@FXML
	public void Btn_Enter(ActionEvent event) {
		String meatType=input.getText();
		Meat meat = null;
		switch (meatType) {
		case "pork":
			meat = MeatFactory.getMeat("pork");
			break;
		case "beef":
			meat = MeatFactory.getMeat("beef");
			break;
		case "chicken":
			meat = MeatFactory.getMeat("chicken");
			break;
		default:
			showText.appendText("Sorry, your input is not correct!\n");
		}
		if (meat != null) {
			showText.appendText(meat.cook()+"\n");
		}
	}
}
